package com.example.books.program

/**
 * @title: Closure
 * @projectName bigdata
 * @Version: 1.0
 * @description: 函数值和闭包
 * @author leali
 * @date 2022/6/1 23:07
 */
object Closure {

  /**
   * 楸树想加 DRY
   * @param number 数字
   * @param codeBlock 代码块
   * @return
   */
  def totalResultOverRange(number: Int, codeBlock: Int => Int): Int = {
    var result: Int = 0
    for (num <- 1 to  number) {
      result += codeBlock(num)
    }
    result
  }
}
